package com.ebupt.migu.music.popup.schedule;

import com.ebupt.migu.music.popup.service.impl.ActivityToRedis;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author tz
 */
@Slf4j
@Component
@EnableScheduling
public class ActivityTask {

    @Autowired
    private ActivityToRedis activityToRedis;

    @Async("taskExecutor")
    @Scheduled(cron = "${cron.updateActivity}")
    public void updateActivity(){
        activityToRedis.setActivityToRedis();
        activityToRedis.setAdsToRedis();
    }

    /**
     * 每天凌晨0点执行
     * <br>
     * 修改redis过期的活动状态
     */
    @Async("taskExecutor")
    @Scheduled(cron = "${cron.cleanDefunctActivity}")
    public void cleanDefunctActivity() {
        activityToRedis.cleanDefunctActivity();
    }
}
